package Test4;
/*新闻类
 *编号（int类型）、标题、内容和点击数，实现Comparable接口，按照编号正序排列；*/

public class News {
    Comparable comparable;
    private int NewsNum;
    private String title;
    private String content;
    private int hits;

    public News() {
    }
    public News(Comparable comparable, int newsNum, String title, String content, int hits) {
        this.comparable = comparable;
        this.NewsNum = newsNum;
        this.title = title;
        this.content = content;
        this.hits = hits;
    }

    public int getNewsNum() {
        return NewsNum;
    }
    public void setNewsNum(int newsNum) {
        this.NewsNum = newsNum;
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public int getHits() {
        return hits;
    }
    public void setHits(int hits) {
        this.hits = hits;
    }
    public Comparable getComparable() {
        return comparable;
    }
    public void setComparable(Comparable comparable) {
        this.comparable = comparable;
    }

    public int compareToNews(News news){
        int a=0;
        int hits1=this.getComparable().compareTo(news);
        if(this.getHits()>hits1){
            a=-1;
        }else if (this.getHits()==hits1){
            a=0;
        }else if (this.getHits()<hits1){
            a=1;
        }
        return a;
    }
}
